package com.primeton.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //包下的类，生成接口文档
                .apis(RequestHandlerSelectors.basePackage("com.primeton.controller"))
                .paths(PathSelectors.any())
                .build();
    }


    //配置API的基本信息，会在http://项目实际地址/swagger-ui.html页面显示
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("EpApi")
                .description("ep文档")
                //地址：http://localhost:8010/swagger-ui.html
//                ... doc.html
                .termsOfServiceUrl("http://localhost:8010")
                .version("1.0")
                .build();
    }
}
